package com.ybk.zs.common.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
 * 统一的日志输出工具
 * @author Administrator
 *
 */
public class LoggerUtil {

	private final static Logger logger = LoggerFactory.getLogger(LoggerUtil.class);
	

	public static void debug(String...msgs){
		StringBuffer stringBuffer = new StringBuffer();
		if(msgs!=null){
			for(Object msg:msgs){
				 stringBuffer.append(","+String.valueOf(msg));
			}
		   logger.debug(stringBuffer.substring(1));
		}
	}
	

	public static void info(String...msgs){
		StringBuffer stringBuffer = new StringBuffer();
		if(msgs!=null){
			for(Object msg:msgs){
				 stringBuffer.append(","+String.valueOf(msg));
			}
		   logger.info(stringBuffer.substring(1));
		}
	}
	

	public static void error(Throwable t,String...msgs){
		StringBuffer stringBuffer = new StringBuffer();
		if(msgs!=null){
			for(Object msg:msgs){
				 stringBuffer.append(","+String.valueOf(msg));
			}
		   logger.error(stringBuffer.substring(1), t);
		}
	}
	
	
	public static void debugObjectInfo(Object data,String...msgs){
		StringBuffer stringBuffer = new StringBuffer();
		String content = "";
		if(msgs!=null){
			for(Object msg:msgs){
				 stringBuffer.append(","+String.valueOf(msg));
			}
			if(stringBuffer.length()>0)
				content = stringBuffer.substring(1);
		}
		if(data!=null){
			String dataString = JsonUtil.tranObjectToJsonStr(data);
			logger.info(content+" data 内容为： "+dataString);
		}else{
			logger.info(content+"data为空");
		}
		
	}
	
	
//	public static void main(String...args){
//		try{
//			System.out.println("..................");
//			debug("这是debug的信息");
//			info("这是info的信息");
//			String r=null;
//			r.charAt(0);
//			System.out.println("测试");
//		}catch(Exception e){
//			//e.printStackTrace();
//			error(e,"出错了");
//		}
//		System.out.println("end");
//
//	}

	
}
